Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce complexity of cypress commands #998

Merged
merged 10 commits into from
Nov 9, 2023
Merged

Conversation

max-nextcloud
Copy link
Collaborator

@max-nextcloud max-nextcloud commented Nov 8, 2023

📝 Summary

With time we build up quite a bit of complexity in cypress commands that is not necessary.
This PR tries to reduce it step by step, commit by commit.

Best reviewed on a per commit basis I think.

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests
  • Documentation (README or documentation) has been updated or is not required

Copy link

cypress bot commented Nov 8, 2023

1 flaky test on run #1269 ↗︎

0 253 0 0 Flakiness 1

Details:

Reduce complexity of cypress commands
Project: Collectives Commit: ca288be30d
Status: Passed Duration: 09:12 💡
Started: Nov 9, 2023 8:48 PM Ended: Nov 9, 2023 8:57 PM
Flakiness  cypress/e2e/page-list.spec.js • 1 flaky test • Nextcloud stable27

View
Output

Test Artifacts
Page list > Page trash > allows to trash and restore page with subpage and attachment Test Replay Screenshots

Review all test suite changes for PR #998 ↗︎

@max-nextcloud max-nextcloud force-pushed the test/cypress-cleanup branch 4 times, most recently from 216f1ea to d5865f5 Compare November 9, 2023 11:10
@max-nextcloud max-nextcloud marked this pull request as ready for review November 9, 2023 12:46
@max-nextcloud max-nextcloud requested a review from mejo- November 9, 2023 12:46
@max-nextcloud max-nextcloud force-pushed the test/cypress-cleanup branch 2 times, most recently from 4c8f582 to 79ca16a Compare November 9, 2023 14:55
Copy link
Member

@mejo- mejo- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, thanks for diving so deep into improving the logic of our custom Cypress commands. Code changes look great and quite sophisticated (to an extend that I struggled a bit to follow the logic).

cypress/support/commands.js Outdated Show resolved Hide resolved
cypress/support/commands.js Show resolved Hide resolved
cypress/support/commands.js Show resolved Hide resolved
cypress/support/commands.js Show resolved Hide resolved
Remove the handling of an existing collective during creation
as we always delete the collective first.

Signed-off-by: Max <[email protected]>
`@nextcloud/axios` deals with request tokens already.
If the initial request fails with a 412 it will get a request token and retry:
https://github.com/nextcloud-libraries/nextcloud-axios/blob/master/lib/interceptors/csrf-token.ts

The additional request is fast so we can reduce the complexity of our test here.

Signed-off-by: Max <[email protected]>
`.findBy({ sanitizedName: name })` is the same as
`.invoke(find, c => c.sanitizedName === name)`.

But it will log the properties the item is selected by.

Signed-off-by: Max <[email protected]>
When used as a child command expects an object to be yielded
and merges it into the payload:
`cy.wrap({ id: 123 }).dispatch(SOME_ACTION, { value: 'Hello' })`
will dispatch `SOME_ACTION` with a payload of `{ id: 123, value: \'Hello\'}`.

If null is yielded the action won't be dispatched.
This is useful for cleanup commands like `deleteCollective`.

Signed-off-by: Max <[email protected]>
@max-nextcloud max-nextcloud merged commit 059b453 into main Nov 9, 2023
49 checks passed
@delete-merged-branch delete-merged-branch bot deleted the test/cypress-cleanup branch November 9, 2023 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants